package com.kitchen.ui.button
{
	import com.kitchen.AbstractButton;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class ScrollButton extends AbstractButton
	{
		public function ScrollButton(bitMapData:BitmapData)
		{
			super(bitMapData);
		}
		
		override protected function layout(bitdata:BitmapData):void{
			this.bitmap = new Bitmap(this.getBitmapData(bitdata));
			var shape:Shape = new Shape();
			shape.graphics.beginFill(0xffffff, 1);
			shape.graphics.drawRect(0, -this.h/2, this.w, this.h);
			shape.graphics.endFill();
			this.mask = shape;
			this.addChild(shape);
			this.bitmap.y = -this.h/2;
			this.addChild(this.bitmap);
		}
		
		override protected function getBitmapData(bitdata:BitmapData):BitmapData{
			this.w = 20;
			this.h = 60;
			var rec:Rectangle = new Rectangle(490, 340, this.w*3, this.h);
			var bit:BitmapData = new BitmapData(rec.width, rec.height);
			bit.copyPixels(bitdata, rec, new Point());
			return bit;
		}
		
		override protected function onMouseOver(me:MouseEvent):void{
			this.offsetX(20);
		}
		
		override protected function onMouseDown(me:MouseEvent):void{
			this.offsetX(40);
		}
	}
}